package com.fkdx.webman.controller;

import com.fkdx.dao.entity.PageResult;
import com.fkdx.service.TaskService;
import com.fkdx.service.TicalService;
import com.fkdx.service.dto.*;
import org.springframework.web.bind.annotation.*;
import com.fkdx.common.dto.ResponseDTO;
import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 提卡controller
 */
@RestController
@RequestMapping("/tical")
public class TicalController {

    @Resource
    private TicalService ticalService;

    @GetMapping("/list")
    public PageResult<TicalQueryResp> getTicalList(TicalQueryReq req) {
        return ticalService.getTicalList(req);
    }

    @GetMapping("/form")
    public TicalQueryResp getTicalForm(Long id) {
        return ticalService.getTicalForm(id);
    }

    @PostMapping("/save")
    public ResponseDTO<String> saveTicalForm(@RequestBody @Valid TicalReq req) {
        ticalService.saveTicalForm(req);
        return ResponseDTO.buildSuccessDataResp("ok");
    }

    @PostMapping("/confirm")
    public ResponseDTO<String> confirm(@RequestBody @Valid TicalReq req) {

        ticalService.confirm(req);
        return ResponseDTO.buildSuccessDataResp("ok");
    }

    @PostMapping("/remove")
    public ResponseDTO<String> removeTicalList(@RequestBody Long[] id) {
        ticalService.removeTicalList(id);
        return ResponseDTO.buildSuccessDataResp("ok");
    }
}
